package cn.doitedu.sql;

import org.apache.flink.streaming.api.environment.StreamExecutionEnvironment;
import org.apache.flink.table.api.bridge.java.StreamTableEnvironment;
import org.apache.flink.table.catalog.hive.HiveCatalog;

public class _21_HiveCatalog_Demo2 {

    public static void main(String[] args) {

        StreamExecutionEnvironment env = StreamExecutionEnvironment.getExecutionEnvironment();
        StreamTableEnvironment tenv = StreamTableEnvironment.create(env);

        // 向tenv表环境中注册一个hiveCatalog
        HiveCatalog hiveCatalog = new HiveCatalog("hive", "default", "./hive_conf");
        tenv.registerCatalog("hive_catalog",hiveCatalog);


        // 可以直接查询之前在hive_catalog中创建的库和表
        // hive_catalog.doit46_flink.score_kfk_1
        tenv.executeSql("use catalog hive_catalog");
        tenv.executeSql("show tables from doit46_flink").print();

        tenv.executeSql("use doit46_flink");

        tenv.executeSql("select * from score_kfk_1").print();



    }


}
